import { createWebHistory, createRouter } from "vue-router";
import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    hidden: true,
  },
  {
    path: "/register",
    component: () => import("@/views/register"),
    hidden: true,
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/index"),
        name: "Index",
        meta: { title: "首页", icon: "fa-home-lg-alt", affix: true },
      },
    ],
  },
  {
    path: "/sceneexamine",
    component: Layout,
    hidden: true,
    redirect: "/sceneexamine/mapSurvey",
    children: [
      {
        path: "/sceneexamine/mapSurvey",
        component: () =>
          import("@/views/taskmanage/sceneexamine/mapSurvey.vue"),
        name: "mapSurvey",
        meta: { noCache: true, title: "地图新建调研点" },
      },
      {
        path: "/sceneexamine/viewTrack",
        component: () =>
          import("@/views/taskmanage/sceneexamine/viewTrack.vue"),
        name: "viewTrack",
        meta: { noCache: true, title: "轨迹查看" },
      },
    ],
  },
  {
    path: "/earthquakeSetting",
    component: Layout,
    hidden: true,
    redirect: "/earthquakeSetting/PointSet",
    children: [
      {
        path: "/earthquakeSetting/PointSet",
        component: () =>
          import("@/views/earthquakeLossesEstimation/earthquakeSetting/PointSet/index.vue"),
        name: "earthquakeSettingPoint",
        meta: { noCache: true, title: "点状|断层|公里格网设定地震" },
      },
      {
        path: "/earthquakeSetting/Influenceflied",
        component: () =>
          import("@/views/earthquakeLossesEstimation/earthquakeSetting/Influenceflied/index.vue"),
        name: "earthquakeInfluenceflied",
        meta: { noCache: true, title: "地图查看结果" },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: () => import("@/views/system/user/profile/index"),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" },
      },
    ],
  },
  {
    path: "/system/user-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "role/:userId(\\d+)",
        component: () => import("@/views/system/user/authRole"),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/system/user" },
      },
    ],
  },
  {
    path: "/system/role-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "user/:roleId(\\d+)",
        component: () => import("@/views/system/role/authUser"),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/system/role" },
      },
    ],
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:dictId(\\d+)",
        component: () => import("@/views/system/dict/data"),
        name: "Data",
        meta: { title: "字典数据", activeMenu: "/system/dict" },
      },
    ],
  },
  {
    path: "/monitor/job-log",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        component: () => import("@/views/monitor/job/log"),
        name: "JobLog",
        meta: { title: "调度日志", activeMenu: "/monitor/job" },
      },
    ],
  },
  {
    path: "/tool/gen-edit",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:tableId(\\d+)",
        component: () => import("@/views/tool/gen/editTable"),
        name: "GenEdit",
        meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
      },
    ],
  },
  {
    path: "/taskmanage",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "任务管理", icon: "taskmanage" },
    children: [
      {
        path: "group",
        component: () => import("@/views/taskmanage/group/index"),
        name: "group",
        meta: { title: "小组管理", icon: "group" },
      },
      {
        path: "assess",
        component: () => import("@/views/taskmanage/assess/index"),
        name: "assess",
        meta: { title: "预评估任务管理", icon: "assess" },
      },
      {
        path: "sceneexamine",
        component: () => import("@/views/taskmanage/sceneexamine/index"),
        name: "sceneexamine",
        meta: { title: "现场调查任务管理", icon: "sceneexamine" },
      },
    ],
  },
  {
    path: "/basedatamanage",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "基础数据管理", icon: "basedatamanage" },
    children: [
      {
        path: "spaceData",
        component: () => import("@/views/basedatamanage/spaceData/index"),
        name: "spaceData",
        meta: { title: "空间数据展示", icon: "spaceData" },
      },
      {
        path: "singleBuilding",
        component: () => import("@/views/basedatamanage/singleBuilding/index"),
        name: "singleBuilding",
        meta: {  title: "建筑物单体数据", icon: "singleBuilding",noCache: true, },
      },
      {
        path: "samplingSurvey",
        component: () => import("@/views/basedatamanage/samplingSurvey/index"),
        name: "samplingSurvey",
        meta: { noCache: true, title: "抽样调查点概况信息", icon: "samplingSurvey" },
      },
      {
        path: "disasterRisk",
        component: () => import("@/views/basedatamanage/disasterRisk/index"),
        name: "disasterRisk",
        meta: { noCache: true, title: "灾害风险点信息", icon: "disasterRisk" },
      },
      {
        path: "difference",
        component: () => import("@/views/basedatamanage/areaLethalityDifference/index"),
        name: "difference",
        meta: { title: "区县致死性差异性指标", icon: "difference" },
      },
      {
        path: "historyRisk",
        component: () => import("@/views/basedatamanage/historyRisk/index"),
        name: "historyRisk",
        meta: { title: "历史地震信息", icon: "historyRisk" },
      },
      {
        path: "historyDisasterData",
        component: () => import("@/views/basedatamanage/historyDisasterData/index"),
        name: "historyDisasterData",
        meta: { title: "历史地震灾害数据", icon: "historyDisasterData" },
      },
      {
        path: "historyAssessData",
        component: () => import("@/views/basedatamanage/historyAssessData/index"),
        name: "historyAssessData",
        meta: { title: "历史预评估数据", icon: "historyAssessData" },
      },
      {
        path: "buildVulnerability",
        component: () => import("@/views/basedatamanage/buildVulnerability/index"),
        name: "buildVulnerability",
        meta: { title: "建筑物易损性数据", icon: "BuildVulnerability" },
      },
      {
        path: "populationCensus",
        component: () => import("@/views/basedatamanage/populationCensus/index"),
        name: "populationCensus",
        meta: { title: "人口普查数据", icon: "populationCensus" },
      },
      {
        path: "gdpData",
        component: () => import("@/views/basedatamanage/gdpData/index"),
        name: "gdpData",
        meta: { title: "GDP数据", icon: "gdpData" },
      },
      {
        path: "housingCost",
        component: () => import("@/views/basedatamanage/housingCost/index"),
        name: "housingCost",
        meta: { title: "房屋造价数据", icon: "housingCost" },
      },
      {
        path: "majorProject",
        component: () => import("@/views/basedatamanage/majorProject/index"),
        name: "majorProject",
        meta: { title: "重大工程基础设施", icon: "majorProject " },
      },
      {
        path: "areaCountyOverview",
        component: () => import("@/views/basedatamanage/areaCountyOverview/index"),
        name: "areaCountyOverview",
        meta: { title: "综合概况信息", icon: "areaCountyOverview " },
      },
      {
        path: "populationBuildProfiles",
        component: () => import("@/views/basedatamanage/populationBuildProfiles/index"),
        name: "populationBuildProfiles",
        meta: { title: "人口和建筑物概况", icon: "populationBuildProfiles " },
      },
      {
        path: "emergencyPreparedness",
        component: () => import("@/views/basedatamanage/emergencyPreparedness/index"),
        name: "emergencyPreparedness",
        meta: { title: "应急准备情况", icon: "emergencyPreparedness" },
      },
    ],
  },
  {
    path: "/modelmanage",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "模型管理", icon: "modelmanage" },
    children: [

      {
        path: "modeldifference",
        component: () => import("@/views/modelmanage/modelareaLethalityDifference/index"),
        name: "modeldifference",
        meta: { title: "区县致死性差异性指标权重", icon: "modeldifference" },
      },
      {
        path: "casualties",
        component: () => import("@/views/modelmanage/casualties/index"),
        name: "casualties",
        meta: { title: "人员伤亡计算模型", icon: "casualties" },
      },
      {
        path: "intensity",
        component: () => import("@/views/modelmanage/intensity/index"),
        name: "intensity",
        meta: { title: "地震烈度衰减关系模型", icon: "intensity" },
      },
      {
        path: "economic",
        component: () => import("@/views/modelmanage/economic/index"),
        name: "economic",
        meta: { title: "经济损失计算模型", icon: "economic" },
      },
      {
        path: "rescueforce",
        component: () => import("@/views/modelmanage/rescueforce/index"),
        name: "rescueforce",
        meta: { title: "救援力量需求评估模型", icon: "rescueforce" },
      },
      {
        path: "resettlement",
        component: () => import("@/views/modelmanage/resettlement/index"),
        name: "resettlement",
        meta: { title: "需安置人员计算模型", icon: "resettlement" },
      },
      {
        path: "material",
        component: () => import("@/views/modelmanage/material/index"),
        name: "material",
        meta: { title: "物资需求评估模型", icon: "material" },
      },

    ],
  },
  {
    path: "/suggestions",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "对策建议管理", icon: "suggestions" },
    children: [
      {
        path: "scenarios",
        component: () => import("@/views/suggestions/scenarios/index"),
        name: "scenarios",
        meta: { title: "灾害情景管理", icon: "scenarios" },
      },
      {
        path: "annualrisk",
        component: () => import("@/views/suggestions/annualrisk/index"),
        name: "annualrisk",
        meta: { title: "年度风险应对策略管理", icon: "annualrisk" },
      },
      {
        path: "preparedness",
        component: () => import("@/views/suggestions/preparedness/index"),
        name: "preparedness",
        meta: { title: "应急备灾对策管理 ", icon: "preparedness" },
      },
      {
        path: "disposition",
        component: () => import("@/views/suggestions/disposition/index"),
        name: "disposition",
        meta: { title: "应急处置对策管理", icon: "disposition" },
      },
    ],
  },
  {
    path: "/resultManag",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "成果管理", icon: "resultManag" },
    children: [
      {
        path: "reportManger",
        component: () => import("@/views/resultManag/reportManger/index"),
        name: "reportManger",
        meta: { title: "报告管理", icon: "reportManger" },
      },
      {
        path: "chartManger",
        component: () => import("@/views/resultManag/chartManger/index"),
        name: "chartManger",
        meta: { title: "图件管理", icon: "chartManger" },
      },
      {
        path: "ypgResult",
        component: () => import("@/views/resultManag/ypgResult/index"),
        name: "ypgResult",
        meta: { title: "预评估结果上传", icon: "ypgResult" },
      },
      {
        path: "reportCheck",
        component: () => import("@/views/resultManag/reportCheck/index"),
        name: "reportCheck",
        meta: { title: "报告审核", icon: "reportCheck" },
      },
      {
        path: "reportModule",
        component: () => import("@/views/resultManag/reportModule/index"),
        name: "reportModule",
        meta: { title: "报告模板管理", icon: "reportModule" },
      },
      {
        path: "chartTypeManage",
        component: () => import("@/views/resultManag/chartTypeManage/index"),
        name: "chartTypeManage",
        meta: { title: "图件类型管理", icon: "chartTypeManage" },
      },
      {
        path: "chartTempManage",
        component: () => import("@/views/resultManag/chartTempManage/index"),
        name: "chartTempManage",
        meta: { title: "图件模板管理", icon: "chartTempManage" },
      }
    ],
  },
  {
    path: "/analyse",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "对策建议分析", icon: "analyse" },
    children: [
      {
        path: "suggestAnalysis",
        component: () => import("@/views/analyse/suggestAnalysis/index"),
        name: "suggestAnalysis",
        meta: { title: "对策建议分析", icon: "analyse" },
      },
    ]
  },
  {
    path: "/earthquakeLossesEstimation",
    component: Layout,
    hidden: true,
    meta: { title: "设定地震灾害损失评估" },
    children: [
      {
        path: "earthquakeSetting",
        component: () => import("@/views/earthquakeLossesEstimation/earthquakeSetting/index"),
        name: 'earthquakeSetting',
        meta: { title: "设定地震", icon: 'earthquakeSetting' },
      },
      {
        path: "earthquakeDetail",
        component: () => import("@/views/earthquakeLossesEstimation/earthquakeSetting/earthquakeDetail"),
        name: 'earthquakeDetail',
      },
      {
        path: "historySettingPoint",
        component: () =>
            import("@/views/earthquakeLossesEstimation/historySettingPoint/index.vue"),
        name: "historySettingPoint",
        meta: { title: "历史设定地震点数据", icon: 'historySettingPoint' },
      },
    ]
  },
  {
    path: "/assistPolicy",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "辅助决策", icon: "assistPolicy" },
    children: [
      {
        path: "parameterSettings",
        component: () => import("@/views/assistPolicy/parameterSettings/index"),
        name: "parameterSettings",
        meta: { title: "参数设置", icon: "parameterSettings" },
      },
      {
        path: "analysisResultQuery",
        component: () => import("@/views/assistPolicy/analysisResultQuery/index"),
        name: "analysisResultQuery",
        meta: { title: "分析结果查询", icon: "analysisResultQuery" },
      },
      {
        path: "zhfzjcgl",
        component: () => import("@/views/assistPolicy/zhfzjcgl/index"),
        name: "zhfzjcgl",
        meta: { title: "震后辅助决策管理", icon: "zhfzjcgl" },
      },
      {
        path: "DrawingsManage",
        component: () => import("@/views/assistPolicy/DrawingsManage/index"),
        name: "DrawingsManage",
        meta: { title: "图件管理", icon: "DrawingsManage" },
      },
    ]
  },
  {
    path: "/structureType",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "结构类型设置", icon: "structureType" },
    children: [
      {
        path: "structureTypeSet",
        component: () => import("@/views/structureType/structureTypeSet/index"),
        name: "structureTypeSet",
        meta: { title: "结构类型设置", icon: "structureTypeSet" },
      },
    ]
  },
  // 空间数据
  {
    path: "/space",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "空间数据管理" },
    children: [
      {
        path: "spaceData",
        component: () => import("@/views/basedatamanage/spaceData/index"),
        name: "spaceData",
        meta: { title: "空间数据展示", icon: "spaceData" },
      },
    ]
  },
  // 现场调查数据管理
  {
    path: "/investigation",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "现场调查数据管理" },
    children: [
      {
        path: "singleBuilding",
        component: () => import("@/views/basedatamanage/singleBuilding/index"),
        name: "singleBuilding",
        meta: { noCache: true, title: "建筑物单体数据", icon: "singleBuilding" },
      },
      {
        path: "samplingSurvey",
        component: () => import("@/views/basedatamanage/samplingSurvey/index"),
        name: "samplingSurvey",
        meta: { noCache: true, title: "抽样调查点概况信息", icon: "samplingSurvey" },
      },
      {
        path: "disasterRisk",
        component: () => import("@/views/basedatamanage/disasterRisk/index"),
        name: "disasterRisk",
        meta: { noCache: true, title: "灾害风险点信息", icon: "disasterRisk" },
      },
      {
        path: "difference",
        component: () => import("@/views/basedatamanage/areaLethalityDifference/index"),
        name: "difference",
        meta: { title: "区县致死性差异性指标", icon: "difference" },
      }
    ]
  },
  // 工作考评
  {
    path: "/workEvaluation",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "工作考评" },
    children: [
      {
        path: "evaluationStandardSetup",
        redirect:'/workEvaluation/evaluationStandardSetup/appraisalDatabaseManage',
        component: () => import("@/views/workEvaluation/evaluationStandardSetup/main"),
        name: "evaluationStandardSetup",
        alwaysShow: true,
        meta: { title: "考评标准建立", icon: "evaluationStandardSetup" },
        children:[
          {
            path: "appraisalDatabaseManage",
            component: () => import("@/views/workEvaluation/evaluationStandardSetup/appraisalDatabaseManage/index"),
            name: "appraisalDatabaseManage",
            meta: { noCache: true, title: "考评库管理", icon: "appraisalDatabaseManage" },
          },
          {
            path: "threeLevelIndexLibraryManage",
            component: () => import("@/views/workEvaluation/evaluationStandardSetup/threeLevelIndexLibraryManage/index"),
            name: "threeLevelIndexLibraryManage",
            meta: { noCache: true, title: "三级指标库管理", icon: "threeLevelIndexLibraryManage" },
          },
        ]
      },
      {
        path: "appraisalTaskManagement",
        component: () => import("@/views/workEvaluation/appraisalTaskManagement/main"),
        name: "appraisalTaskManagement",
        // alwaysShow: true,
        meta: { noCache: true, title: "考评任务管理", icon: "appraisalTaskManagement" },
        children:[
          {
            path: "addAppraisalTaskManagement",
            component: () => import("@/views/workEvaluation/appraisalTaskManagement/addAppraisalTaskManagement/index"),
            name: "addAppraisalTaskManagement",
            meta: { noCache: true, title: "新建考评任务", icon: "addAppraisalTaskManagement" },
          },
          {
            path: "appraisalTaskManage",
            component: () => import("@/views/workEvaluation/appraisalTaskManagement/appraisalTaskManage/index"),
            name: "appraisalTaskManage",
            meta: { noCache: true, title: "考评任务管理", icon: "appraisalTaskManage" },
          },
        ]
      },
      {
        path: "expertScore",
        component: () => import("@/views/workEvaluation/expertScore/index"),
        name: "expertScore",
        // alwaysShow: true,
        meta: { noCache: true, title: "专家评分", icon: "expertScore" },
      },
      {
        path: "EvaluationRankingView",
        component: () => import("@/views/workEvaluation/EvaluationRankingView/index"),
        name: "EvaluationRankingView",
        // alwaysShow: true,
        meta: { noCache: true, title: "考评排名查看（省局）", icon: "EvaluationRankingView" },
      },
      {
        path: "evaluationStandardSetup/addEvaluation",
        component: () => import("@/views/workEvaluation/evaluationStandardSetup/addEvaluation/index"),
        name: "addEvaluation",
        meta: { noCache: true, title: "新建考评", icon: "addEvaluation" },
      },
      {
        path: "evaluationStandardSetup/addThreeLevelIndex",
        component: () => import("@/views/workEvaluation/evaluationStandardSetup/addThreeLevelIndex/index"),
        name: "addThreeLevelIndex",
        meta: { noCache: true, title: "新建三级指标", icon: "addThreeLevelIndex" },
      },
      {
        path: "appraisalTaskManagement/detailIndex",
        component: () => import("@/views/workEvaluation/appraisalTaskManagement/detailIndex/index"),
        name: "detailIndex",
        meta: { noCache: true, title: "得分详情", icon: "detailIndex" },
      },
      {
        path: "appraisalTaskManagement/rankingPreview",
        component: () => import("@/views/workEvaluation/appraisalTaskManagement/rankingPreview/index"),
        name: "rankingPreview",
        meta: { noCache: true, title: "排名预览", icon: "rankingPreview" },
      },
    ]
  },
  //数据量统计
  {
    path:'/dataVolume',
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "数据量统计" },
    children:[
      {
        path: "dataVolumeStatistics",
        component: () => import("@/views/dataVolume/dataVolumeStatistics/index"),
        name: "dataVolumeStatistics",
        meta: { title: "数据量统计", icon: "dataVolumeStatistics", noCache: true },
      },
    ]
  }
];

const router = createRouter({
  history: createWebHistory('ypg'),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
